/**
 * 
 */
package com.videoshare.user;

/**
 * @author Administrator
 *
 */
import org.apache.struts.action.*;
import javax.servlet.http.*;
import org.apache.commons.logging.*;
import java.util.*;

public class UserRegistrationForm extends ActionForm
{
	
	private static Log log = LogFactory.getLog(UserRegistrationForm.class);
	
	private String firstName = null;
	private String lastName = null;
	private String userName = null;
	private String password = null;
	private String passwordCheck = null;
	private String email = null;
	private String phone = null;
	private boolean registered = false;
	private String profile = null;
	private String regDate = null;
	private String endDate = null;
	
	private int page = 0;
	
	private String [] selectedUser = null;
	
	//private boolean registered;
	
	/**
	 * @return Returns the email.
	 */
	public String getEmail() {
		return email;
	}
	/**
	 * @param email The email to set.
	 */
	public void setEmail(String email) {
		this.email = email;
	}
	
	/**
	 * @return Returns the firstName.
	 */
	public String getFirstName() {
		return firstName;
	}
	/**
	 * @param firstName The firstName to set.
	 */
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	/**
	 * @return Returns the lastName.
	 */
	public String getLastName() {
		return lastName;
	}
	/**
	 * @param lastName The lastName to set.
	 */
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	/**
	 * @return Returns the password.
	 */
	public String getPassword() {
		return password;
	}
	/**
	 * @param password The password to set.
	 */
	public void setPassword(String password) {
		this.password = password;
	}
	/**
	 * @return Returns the passwordCheck.
	 */
	public String getPasswordCheck() {
		return passwordCheck;
	}
	/**
	 * @param passwordCheck The passwordCheck to set.
	 */
	public void setPasswordCheck(String passwordCheck) {
		this.passwordCheck = passwordCheck;
	}
	/**
	 * @return Returns the phone.
	 */
	public String getPhone() {
		return phone;
	}
	/**
	 * @param phone The phone to set.
	 */
	public void setPhone(String phone) {
		this.phone = phone;
	}
	
	
	/**
	 * @return Returns the userName.
	 */
	public String getUserName() {
		return userName;
	}
	/**
	 * @param userName The userName to set.
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	/**
	 * @param endDate The endDate to set.
	 */
	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}
	
	/**
	 * @return Returns the endDate.
	 */
	public String getEndDate() {
		return endDate;
	}
	
	/**
	 * @param regDate The regDate to set.
	 */
	public void setRegDate(String regDate) {
		this.regDate = regDate;
	}
	
	
	/**
	 * @return Returns the regDate.
	 */
	public String getRegDate() {
		return regDate;
	}
	
	
	/**
	 * @return Returns the registered.
	 */
	public boolean isRegistered() {
		return registered;
	}
	/**
	 * @param registered The registered to set.
	 */
	public void setRegistered(boolean registered) {
		this.registered = registered;
	}
	
	/**
	 * @return Returns the profile.
	 */
	public String getProfile() {
		return profile;
	}
	/**
	 * @param profile The profile to set.
	 */
	public void setProfile(String profile) {
		this.profile = profile;
	}
	
	/**
	 * @return Returns the page.
	 */
	public int getPage() {
		return page;
	}
	/**
	 * @param page The page to set.
	 */
	public void setPage(int page) {
		this.page = page;
	}
	
	/**
	 * @return Returns the selectedUser.
	 */
	public String[] getSelectedUser() {
		return selectedUser;
	}
	/**
	 * @param selectedUser The selectedUser to set.
	 */
	public void setSelectedUser(String[] selectedUser) {
		this.selectedUser = selectedUser;
	}
	

	
	public void reset(ActionMapping mapping, HttpServletRequest request)
	{
		firstName = null;
		lastName = null;
		userName = null;
		password = null;
		passwordCheck = null;
		email = null;
		phone = null;
		registered = false;
		profile = null;
		regDate = null;
		endDate = null;
		
		page = 0;
		selectedUser = null;
		
		log.trace("reset");
	}
	
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
	{
		ActionErrors errors = new ActionErrors();
		
		if( (firstName == null) || firstName.trim().equals(""))
		{
			errors.add("firstName", new ActionMessage("userRegistration.firstName.problem"));
		}
		
		if( (lastName == null) || lastName.trim().equals(""))
		{
			errors.add("lastName", new ActionMessage("userRegistration.lastName.problem"));
		}
		
		if( (userName == null) || userName.trim().equals(""))
		{
			errors.add("userName", new ActionMessage("userRegistration.userName.problem"));
		}
		if( (password == null) || password.trim().equals(""))
		{
			errors.add("password", new ActionMessage("userRegistration.password.problem"));
		}
		if( (passwordCheck == null) || passwordCheck.trim().equals(""))
		{
			errors.add("passwordCheck", new ActionMessage("userRegistration.passwordCheck.problem"));
		}
		if( !password.equals(passwordCheck) )
		{
			errors.add("email", new ActionMessage("userRegistration.passwordmatch.problem"));
		}
		if( (email == null) || email.trim().equals(""))
		{
			errors.add("email", new ActionMessage("userRegistration.email.problem"));
		}
		if( (phone == null) || phone.trim().equals(""))
		{
			errors.add("phone", new ActionMessage("userRegistration.phone.problem"));
		}		
		
		
		log.trace("validate");
		
		return errors;
	}
	
	
	
}
